<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="{{asset('admin')}}/lib/html5shiv.js"></script>
<script type="text/javascript" src="{{asset('admin')}}/lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="{{asset('admin')}}/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="{{asset('admin')}}/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="{{asset('admin')}}/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="{{asset('admin')}}/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="{{asset('admin')}}/static/h-ui.admin/css/style.css" />
<script src="/uploadify/jquery.min.js" type="text/javascript"></script>
<script src="/uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="/uploadify/uploadify.css">
<!--[if IE 6]>
<script type="text/javascript" src="{{asset('admin')}}/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>添加课时 - 课时管理</title>
<meta name="keywords" content="H-ui.admin v3.1,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
<meta name="description" content="H-ui.admin v3.1，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
</head>

<body>
<article class="page-container">
	<form class="form form-horizontal" id="form-admin-add">
		{{csrf_field()}}
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>课程：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<select name="course_id" >
				<option value="0">-请选择-</option>
				@foreach($course as $k=>$v)
				<option value="{{$k}}">{{$v}}</option>
				@endforeach
			</select>
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>课时名称：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" autocomplete="off" value=""  name="lesson_name">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>封面图：</label>
		<div class="formControls col-xs-8 col-sm-9">
		<input id="cover_img" name="cover_img" type="file" multiple="true">
		</div>
	</div>
	<div class="row cl">
		<!-- 效果展示 -->
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red"></span></label>
		<div class="formControls col-xs-8 col-sm-9">
			<img id="show_pic" src="" alt="" width="220" height="115">
			
		</div>
	</div>
	<div class="row cl">
	<!-- 显示路径信息 -->
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red"></span></label>
		<div class="formControls col-xs-8 col-sm-9">
		<input type="text" class="input-text" id="img_path"  name="cover_img">
		</div>
	</div>
	
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>视频：</label>
		<div class="formControls col-xs-8 col-sm-9">
		<input id="video" name="video" type="file" multiple="true">
		</div>
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red"></span></label>
		<div class="formControls col-xs-8 col-sm-9">
		<input type="text" class="input-text"  id='video_address' name="video_address" value='' readonly>
		</div>
		
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>时长：</label>
		<div class="formControls col-xs-8 col-sm-9" style="width:80px">
			<input type="number" class="input-text" placeholder="分钟"  name="lesson_duration">
		</div>
		
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>授课老师：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<select name="teachers[]" id="" multiple>
				@foreach($teacher as $k=>$v)
				<option value="{{$k}}">{{$v}}</option>
				@endforeach
			</select>
		</div>
	</div>
	
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">课时描述：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<textarea name="lesson_desc"  class="textarea"  placeholder="说点什么..." dragonfly="true" onKeyUp="$.Huitextarealength(this,100)"></textarea>
			<p class="textarea-numberbar"><em class="textarea-length">0</em>/100</p>
		</div>
	</div>
	<div class="row cl">
		<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
			<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
		</div>
	</div>
	</form>
</article>

<!--_footer 作为公共模版分离出去--> 
<!-- <script type="text/javascript" src="{{asset('admin')}}/lib/jquery/1.9.1/jquery.min.js"></script>  -->
<script type="text/javascript" src="{{asset('admin')}}/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="{{asset('admin')}}/static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="{{asset('admin')}}/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="{{asset('admin')}}/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="{{asset('admin')}}/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="{{asset('admin')}}/lib/jquery.validation/1.14.0/messages_zh.js"></script> 
<script type="text/javascript">
$(function(){
	<?php $timestamp = time();?>
		$(function() {
			$('#video').uploadify({
				'formData'     : {
					'timestamp' : '<?php echo $timestamp;?>',
					'_token'     : '{{csrf_token()}}'
				},
				'swf'      : '/uploadify/uploadify.swf',
				'uploader' : '{{url("admin/upload/up_video")}}',
				//上传给服务器返回的状态
				'onUploadSuccess' : function(file, data, response) {
				    //file 被上传的附件信息
					//data 服务器返回的信息
					//response 返回true/fasle
					// console.log(file+'---'+data+'---'+response);
					var obj = JSON.parse(data);
					$('#video_address').val(obj.path);
				
        }
				
			});
			$('#cover_img').uploadify({
				'formData'     : {
					'timestamp' : '<?php echo $timestamp;?>',
					'_token'     : '{{csrf_token()}}'
				},
				'swf'      : '/uploadify/uploadify.swf',
				'uploader' : '{{url("admin/upload/up_pic")}}',
				//上传给服务器返回的状态
				'onUploadSuccess' : function(file, data, response) {
					// console.log(file+'---'+data+'---'+response);
					var obj = JSON.parse(data);
					$('#img_path').val(obj.path);
					$('#show_pic').attr('src',obj.path);
				
        }
				
			});
		});
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});

	//设置ajax提交 将表单数据给服务器
	$('form').submit(function(e){
		e.preventDefault();//阻止默认事件提交
		var data = $(this).serialize();
		//设置ajax
		$.ajax({
			url:"{{url('admin/lesson/add')}}",
			data:data,
			dataType:'JSON',
			type:'post',
			success:function(msg){
				if(msg.success===true){
					layer.alert('添加数据成功',function(){
					//父页面datatable 的ajax重新获取数据显示(只有先调用了api()方法后 才能重载)
					parent.mydatatable.api().ajax.reload();
		
					layer_close();//关闭当前层
				});
				}else{
					layer.alert('数据添加失败【'+msg.errorinfo+'】',{icon:5});
				}
				
			}
			
		});
	});
});

</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>